<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
//        按照一定模式，从数组和对象中提取值，对变量进行赋值，这被称为解构（Destructuring）
//        let a = 1, b = 2, c = 3;

//        let [a, b, c] = [1, 2, 3];      //数组的解构，变量值跟数据的顺序相关

//        let [a, [b, c]] = [1, [2, 3]];
//        let [a, [b, c]] = [1, 2, 3];        //解构不成功
//        document.writeln(`a = ${a} b = ${b} c = ${c}`);

//        let [a, b, c] = [1, 2];
//        document.writeln(`a = ${a} b = ${b} c = ${c}`); //a = 1 b = 2 c = undefined
//        let [a, b] = [1, 2, 3];
//        document.writeln(`a = ${a} b = ${b}`);      //a = 1 b = 2
//----------------------------------------------------------------------------
//        let [a = 10, b] = [1, 2];
//        document.writeln(`a = ${a} b = ${b}`);      //a = 1 b = 2
//        let [a = 10, b] = [undefined, 2];       //如果值是undefined或者空占位符，就会使用默认值
//        document.writeln(`a = ${a} b = ${b}`);      //a = 10 b = 2
//        let [a = 10, b] = [null, 2];
//        document.writeln(`a = ${a} b = ${b}`);      //a = null b = 2

//        let [a = b, b] = [, 2];
//        document.writeln(`a = ${a} b = ${b}`);      //报错
    </script>
</head>
<body>

</body>
</html>